package com.xoa.controller.party;


import com.xoa.model.party.CommunityWjfxx;
import com.xoa.service.party.CommunityWjfxxService;
import com.xoa.util.DateFormat;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/CommunityWjfxx")
public class CommunityWjfxxController {

    @Autowired
    private CommunityWjfxxService communityWjfxxService;

    /**
     * 查询
     * @param request
     * @param
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("/select")
    @ResponseBody
    public ToJson select(HttpServletRequest request, CommunityWjfxx communityWjfxx, Integer page, Integer pageSize, boolean useFlag, String export, HttpServletResponse response){
        return  communityWjfxxService.select(request,communityWjfxx,page,pageSize,useFlag,export,response);
    }


    /**
     * 修改
     * @param request
     * @param
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public ToJson update(HttpServletRequest request, CommunityWjfxx communityWjfxx, String timeStr){
//        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        try{
//            communityWjfxx.setStartTime(format.parse(timeStart));
//        }catch (Exception e){
//            e.printStackTrace();
//        }
        //转换
        communityWjfxx.setStartTime(DateFormat.getDate(timeStr));
        return  communityWjfxxService.update(request,communityWjfxx);
    }

    /**
     * 删除
     * @param
     * @param
     * @param
     * @param
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ToJson delete(Integer wjfxxId){
        return  communityWjfxxService.delete(wjfxxId);
    }


    /**
     * 添加
     * @param request
     * @param communityWjfxx
     * @param
     * @param
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public ToJson add(HttpServletRequest request, CommunityWjfxx communityWjfxx, String timeStr){
//        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        try{
//            communityWjfxx.setStartTime(format.parse(timeStart));
//        }catch (Exception e){
//            e.printStackTrace();
//        }
        //转换

        communityWjfxx.setStartTime( DateFormat.getDate(timeStr));

        return  communityWjfxxService.add(request,communityWjfxx);
    }
}
